package com.jm.controller;

import com.jm.domain.ResponseResult;
import com.jm.domain.entity.Link;
import com.jm.service.LinkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/content/link")
public class LinkController {
    @Autowired
    private LinkService linkService;

    @GetMapping("/list")
    public ResponseResult list(Integer pageNum, Integer pageSize, String name, String status){
        return linkService.listLink(pageNum,pageSize,name,status);
    }

    @PostMapping
    public ResponseResult save(@RequestBody Link link){
        return linkService.saveLink(link);
    }

    @GetMapping("/{id}")
    public ResponseResult getLinkById(@PathVariable Long id){
        return linkService.getLinkById(id);
    }

    @PutMapping
    public ResponseResult update(@RequestBody Link link){
        return linkService.updateLink(link);
    }

    @DeleteMapping("/{id}")
    public ResponseResult delete(@PathVariable Long id){
        return linkService.deleteLink(id);
    }

}
